package com.symria.server.dao.app;

import java.util.Date;
import java.util.List;

import com.symria.framework.dao.util.TemplateDao;
import com.symria.framework.page.Page;
import com.symria.system.statement.Statement;

public class AppReportDao extends TemplateDao{

	public void searchByAPPandTime(Integer[] appId,Date beginTime,Date endTime,Page page){
		Statement stm=stmsFactory.createStatement("from AppDateReport adr where 1=1");
	    stm.appendBetween("and", "adr.createTime", beginTime, endTime);
		stm.append("and", "or", "adr.appId", "=", appId);
		templateDao.search(stm, page);
	}
	
	public List searchSumByAPPandTime(Integer[] appId,Date time){
		Statement stm=stmsFactory.createStatement("select adr.createTime,sum(adr.cpmShowCount),sum(adr.cpcShowCount),sum(adr.cpmClickCount),sum(adr.cpcClickCount),sum(adr.sureCount),sum(adr.payMoney) from AppDateReport as adr where 1=1");
	    stm.append("and", "adr.createTime", ">", time);
		stm.append("and", "or", "adr.appId", "=", appId);
		stm.addGroupBy("adr.createTime");
		stm.addOrderBy("adr.createTime desc");
		return templateDao.query(stm);
	}
}
